package day06;

import java.util.Arrays;

//数组

public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = {60,50,80,70,20,6,99,4};
        for (int i=0;i<arr.length-1;i++){//控制轮数
            for (int j=0;j<arr.length-1-i;j++){//控制每一轮比较的次数
                if (arr[j]<arr[j+1]){//每一个都是和它的下一个元素比
                    int t = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = t;
                }
            }
        }
        System.out.println(Arrays.toString(arr));


        /*
        //数字复制
        int[] a = {10,20,30,40,50};
        //
        a = Arrays.copyOf(a,a.length+1);//在a的数组上重新扩容
        for (int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }

         */

        /*
        int[] a = {10,20,30,40,50};
        int[] b = new int[6];//0,0,0,0,0,0
        //a:源数组
        //2:源数组的起始下标
        //b:目标数组
        //0:目标数组的起始下标
        //3:要复制的元素个数
        System.arraycopy(a,2,b,0,3);
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }
         */
    }
}
